package com.yanmaohu.yulia.bean;

/**
 * @author Bright Lee
 */
public final class TableReference {

    private int beginIndex;
    private int endIndex;
    private TablePrimaryOrJoinedTable tablePrimaryOrJoinedTable;
    private SampleClause sampleClause;

    public TableReference(TablePrimaryOrJoinedTable tablePrimaryOrJoinedTable,
                          SampleClause sampleClause) {
        this.beginIndex = tablePrimaryOrJoinedTable.getBeginIndex();
        if (sampleClause != null) {
            this.endIndex = sampleClause.getEndIndex();
        } else {
            this.endIndex = tablePrimaryOrJoinedTable.getEndIndex();
        }
        this.tablePrimaryOrJoinedTable = tablePrimaryOrJoinedTable;
        this.sampleClause = sampleClause;
    }

    public int getBeginIndex() {
        return beginIndex;
    }

    public int getEndIndex() {
        return endIndex;
    }

    public TablePrimaryOrJoinedTable getTablePrimaryOrJoinedTable() {
        return tablePrimaryOrJoinedTable;
    }

    public SampleClause getSampleClause() {
        return sampleClause;
    }

}
